package com.david.rabbitdlq.controller;

import com.david.rabbitdlq.entity.Order;
import com.david.rabbitdlq.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    //添加订单
    @PostMapping("/add")
    public Mono<Order> add(@RequestBody Order order) {
        Order o = orderService.add(order);
        return Mono.just(o);
    }

    @PostMapping("/pay")
    public Mono<Order> pay(@RequestBody Order order) {
        Order o = orderService.pay(order);
        return Mono.just(o);
    }
}
